<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>事件的触发</title>
</head>
<body>
     <!-- <input type="button" name="box" value="点我" onclick="alert('今天')">-->
        <div id="btn">aaa</div>


     <script>
       //  document.getElementById('btn').onclick = function() {
       //      alert('hello');
       //  };


         function foo() {
             alert('hello');
         }
         document.getElementById('btn').onclick = foo;

     </script>
</body>
</html>